package mya.mes.mdc.share.vo.plc;

import mya.mes.mdc.model.plc.PlcTagDef;

import java.util.Arrays;

public abstract class PlcTagDefArray<T extends PlcTagDef> {

    protected final static int BIT_ARRAY_LEN = 32;

    private final T[] array;

    public PlcTagDefArray() {
        array = createArray();
        Arrays.fill(array, null);
    }

    protected abstract T[] createArray();

    public PlcTagDefArray(T[] array) {
        this.array = array;
    }

    public T get(Integer index) {
        if (index == null || array == null) {
            return null;
        }

        if (index < 0 || index >= array.length) {
            return null;
        }

        return array[index];
    }


    public void set(T vo) {

//        if(vo.getTagIndex() == null) {
//
//        }
        array[vo.getBitIndex()] = vo;
    }


}
